import request from '@/utils/request'

// 保养计划API接口
export const maintenancePlanApi = {
  // 分页查询保养计划列表
  getMaintenancePlanPage(params) {
    return request({
      url: '/maintenance-plan/page',
      method: 'post',
      data: params
    })
  },

  // 根据ID查询保养计划详情
  getMaintenancePlanById(planId) {
    return request({
      url: `/maintenance-plan/${planId}`,
      method: 'get'
    })
  },

  // 新增保养计划
  addMaintenancePlan(data) {
    return request({
      url: '/maintenance-plan/create',
      method: 'post',
      data
    })
  },

  // 创建保养计划（别名）
  createMaintenancePlan(data) {
    return request({
      url: '/maintenance-plan/create',
      method: 'post',
      data
    })
  },

  // 修改保养计划
  updateMaintenancePlan(data) {
    return request({
      url: '/maintenance-plan/update',
      method: 'put',
      data
    })
  },

  // 删除保养计划
  deleteMaintenancePlan(planId) {
    return request({
      url: `/maintenance-plan/${planId}`,
      method: 'delete'
    })
  },

  // 执行保养计划
  executeMaintenancePlan(planId) {
    return request({
      url: `/maintenance-plan/execute/${planId}`,
      method: 'post'
    })
  },

  // 更新保养计划状态
  updateMaintenancePlanStatus(planId, status) {
    return request({
      url: '/maintenance-plan/update-status',
      method: 'put',
      params: {
        maintenancePlanId: planId,
        planStatus: status
      }
    })
  },

  // 获取设备保养计划
  getEquipmentMaintenancePlans(equipmentId) {
    return request({
      url: `/maintenance-plan/equipment/${equipmentId}`,
      method: 'get'
    })
  }
}